#include "mainwindow.h"
#include <QMessageBox>
#include <QMenu>
#include <QMenuBar>
#include <QToolBar>

MainWindow::MainWindow() :
    QMainWindow(0), dm(new DataModel()), cw(new CentralWidget(dm))
{
    m_all = new QAction("All", this);
    m_fall = new QAction("Fall", this);
    m_winter = new QAction("Winter", this);
    m_summer = new QAction("Summer", this);
    m_spring = new QAction("Spring", this);

    QMenu *menu = new QMenu("Actions", this);
    menu->addAction(m_all);
    menu->addAction(m_winter);
    menu->addAction(m_spring);
    menu->addAction(m_summer);
    menu->addAction(m_fall);
    menuBar()->addMenu(menu);

    QToolBar *full = addToolBar("full");
    full->addAction(m_all);
    QToolBar *partial = addToolBar("partial");
    partial->addAction(m_winter);
    partial->addAction(m_spring);
    partial->addAction(m_summer);
    partial->addAction(m_fall);

    connect(m_all, SIGNAL(triggered()), SLOT(showAll()));
    connect(m_fall, SIGNAL(triggered()), SLOT(showFall()));
    connect(m_winter, SIGNAL(triggered()), SLOT(showWinter()));
    connect(m_spring, SIGNAL(triggered()), SLOT(showSpring()));
    connect(m_summer, SIGNAL(triggered()), SLOT(showSummer()));

    setCentralWidget(cw);
}

void MainWindow::showAll()
{
    dm->setSeason(WINTER | SPRING | SUMMER | FALL);
}

void MainWindow::showSummer()
{
    dm->setSeason(SUMMER);
}

void MainWindow::showWinter()
{
    dm->setSeason(WINTER);
}

void MainWindow::showFall()
{
    dm->setSeason(FALL);
}

void MainWindow::showSpring()
{
    dm->setSeason(SPRING);
}
